package hu.village.mapper;

import hu.village.pojo.Account;
import hu.village.pojo.User;
import hu.village.pojo.Village;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface CommitteeMapper {
    //提交村庄委员绑定信息
    @Insert("insert into village(village_name,address,image,village_leader,phone,committee,state) values (#{villageName},#{address},#{image},#{villageLeader},#{phone},#{committee},#{state})")
    void bindingVillage(Village village);

    //提交本村账目信息
    @Insert("insert into account(village_name,category,info,state,crate_date,update_date,visible) values (#{villageName},#{category},#{info},#{state},#{createTime},#{updateTime},#{visible})")
    void insertAccount(Account account);
    //修改账目
    @Update("update account set village_name = #{villageName},category = #{category},info = #{info},update_date = #{updateTime} where id = #{id}")
    void updateAccount(Account account);

    //根据visible状态来查询账目
    @Select("select * from account where visible = #{visible}")
    List<Account> selectAccountByVisible(Account account);

    //查看提交申请的用户
    @Select("select * from user where status = #{status}")
    List<User> selectUserApplication(Integer status);

    @Update("update user set status = #{status} where id = #{id}")
    void processApplication(int status,Integer id);
}
